package com.lagou.zkboot.web.config;

import com.lagou.zkboot.web.utils.JsonMapper;

public class DataSourceConfig {

    private String url;
    private String username;
    private String password;
    private int maxActive;
    private int initialSize;
    private int minIdle;
//    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
//     <property name="url" value="${jdbc_url}" />
//     <property name="username" value="${jdbc_user}" />
//     <property name="password" value="${jdbc_password}" />
//
//     <property name="filters" value="stat" />
//
//     <property name="maxActive" value="20" />
//     <property name="initialSize" value="1" />
//     <property name="maxWait" value="60000" />
//     <property name="minIdle" value="1" />
//
//     <property name="timeBetweenEvictionRunsMillis" value="60000" />
//     <property name="minEvictableIdleTimeMillis" value="300000" />
//
//     <property name="testWhileIdle" value="true" />
//     <property name="testOnBorrow" value="false" />
//     <property name="testOnReturn" value="false" />
//
//     <property name="poolPreparedStatements" value="true" />
//     <property name="maxOpenPreparedStatements" value="20" />
//
//     <property name="asyncInit" value="true" />
// </bean>

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getMaxActive() {
        return maxActive;
    }

    public void setMaxActive(int maxActive) {
        this.maxActive = maxActive;
    }

    public int getInitialSize() {
        return initialSize;
    }

    public void setInitialSize(int initialSize) {
        this.initialSize = initialSize;
    }

    public int getMinIdle() {
        return minIdle;
    }

    public void setMinIdle(int minIdle) {
        this.minIdle = minIdle;
    }

    @Override
    public String toString() {
        return "DataSourceConfig{" +
                "url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", maxActive=" + maxActive +
                ", initialSize=" + initialSize +
                ", minIdle=" + minIdle +
                '}';
    }

    public static void main(String[] args) {
        DataSourceConfig config = new DataSourceConfig();
        config.setUrl("jdbc:mysql://127.0.0.1:3306/test");
        config.setUsername("root");
        config.setPassword("root");
        config.setMaxActive(5);
        config.setMinIdle(2);
        config.setInitialSize(3);
        System.out.println(JsonMapper.toJsonString(config));
    }
}
